﻿using CommonBase;
using InteractiveWhiteboardManagement.Base.Common;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using SurveillancePro.Base.Common;
using SurveillancePro.Base.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;

namespace PersonnelLocationModule.ViewModels
{
    /// <summary>
    /// 人员定位
    /// </summary>
    public class ViewModel_PersonnelLocation : WorkspaceViewModel
    {
        #region Private Fields

        private DelegateCommand<string> _cmdViewPersonnelLocationItem;

        private readonly IRegionManager _regionManager;

        #endregion

        #region Constructor

        public ViewModel_PersonnelLocation(IRegionManager regionManager)
        {
            this._regionManager = regionManager;
        }

        #endregion

        #region Base Class Overrides

        protected override void OnDispose()
        {
        }

        #endregion

        #region Public Properties

        [Display(GroupName = "DelegateCommand")]
        public DelegateCommand<string> Cmd_ViewPersonnelLocationItem
        {
            get
            {
                if (_cmdViewPersonnelLocationItem == null)
                {
                    _cmdViewPersonnelLocationItem = new DelegateCommand<string>(_viewPersonnelLocationItem, _canViewPersonnelLocationItem);
                }
                return _cmdViewPersonnelLocationItem;
            }
        }

        #endregion

        #region Private Methods

        #region DelegateCommand

        private bool _canViewPersonnelLocationItem(string toolkitItem)
        {
            return true;
        }

        /// <summary>
        /// 人员定位功能
        /// </summary>
        /// <param name="personnelLocationItem">人员定位菜单</param>
        private void _viewPersonnelLocationItem(string personnelLocationItem)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(personnelLocationItem))
                    return;

                string displayView = null;
                switch (personnelLocationItem)
                {
                    case "RegionSurveillance":
                        displayView = ViewNames.PersonnelLocationModule_RegionSurveillance;
                        break;
                    case "RegionManagement":
                        break;
                    case "PersonManagement":
                        break;
                    case "TrackReplay":
                        break;


                    default:
                        break;
                }

                if (this._regionManager != null && 
                    !string.IsNullOrWhiteSpace(displayView))
                    this._regionManager.RequestNavigate(RegionNames.ContentRegion, displayView); // 显示区域监控界面
            }
            catch (System.Exception ex)
            {
#if DEBUG
                Debug.WriteLine(ex.Message);
#endif
                MessageBox.Show(ex.Message, ConstantString.MSG_COMPANY);
            }
        }

        #endregion

        #endregion
    }
}
